<?php
/**
 * Created by PhpStorm.
 * User: sofwu
 * Date: 2019/1/14
 * Time: 下午3:22
 */
namespace App\Http\Transformer;

use App\Model\Goods;
use League\Fractal\TransformerAbstract;

class GoodsTransformer extends TransformerAbstract
{
    public function transform(Goods $goods)
    {
        return[
            'id'=> $goods->id,
            'name'=> $goods->name,
            'content'=> $goods->content,
            'pic'=> !$goods->getFirstMediaUrl() ? '' :env('APP_URL').$goods->getFirstMediaUrl(),
        ];
    }
}